10.2   Overview of Transport Layer Ports  
  10.2.1 Multiple conversations between hosts  
At any given moment, thousands of packets providing hundreds of different services traverse a modern network. In many cases, servers provide for a multitude of services which causes unique problems for the addressing of packets. If a server is running both SMTP and WWW, it uses the destination port field to determine what service the source is requesting. The source cannot construct a packet destined for just the server IP address because the destination would not know what service was being requested. A port number must be associated with the conversation between hosts to ensure that the packet reaches the appropriate service on the server. Without a way to distinguish between different conversations, the client would be unable to send both an email and browse a web page, using one server at the same time. A method for transport layer conversations to be separated must be used.

Hosts running TCP/IP associate ports at the transport layer with certain applications. Port numbers are used to keep track of different conversations that cross the network at the same time. Port numbers are needed when a host is communicating with a server running multiple services. Both TCP and UDP use port or socket numbers to pass information to the upper layers.

Application software developers have agreed to use the well-known port numbers that are defined in RFC1700. Any conversation bound for the FTP application uses the standard port number 21. Conversations that do not involve applications with well-known port numbers are assigned port numbers that have been randomly selected from within a specific range. These port numbers are used as source and destination addresses in the TCP segment.

Port numbers have the following assigned ranges:

  • Numbers below 255 are reserved for public applications
  • Numbers from 255-1023 are assigned to companies for marketable applications
  • Numbers above 1023 are unregulated

End systems use port numbers to select proper applications. Source port numbers are dynamically assigned by the originating host, and are usually a number larger than 1023. Port numbers in the range of 0-1023 are controlled by the Internet Assigned Numbers Authority.

Post office box numbers are a good analogy for port numbers. A piece of mail may be sent to a zip code, city, and P.O. box. The zip code and city direct mail to the correct general mail facility while the P.O. box ensures the item is delivered to the one individual to whom the mail is addressed. Similarly, the IP address gets the packet to the correct server, but the TCP or UDP port number guarantees the packet is passed to the correct application.